package com.example.annasbook.processors;

import com.example.annasbook.model.BookModel;
import com.example.annasbook.repository.convert.BookConvert;
import org.springframework.batch.item.ItemProcessor;
import org.springframework.util.StringUtils;

public class BookRedisListProcessor implements ItemProcessor<BookModel, BookModel> {

    @Override
    public BookModel process(BookModel item) throws Exception {
        String url = item.getUrl();
        if (StringUtils.hasText(url)) {
            int lastIndexOf = url.lastIndexOf("/");
            String md5 = url.substring(lastIndexOf + 1);
            item.setMd5(md5);
        }
        return item;
    }
}
